<%@ page import="java.util.List" %>
<%@ page import="com.lagou.module01.bean.ClassGrade" %><%--
  Created by IntelliJ IDEA.
  User: xyk
  Date: 2021/3/15
  Time: 22:54
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <!-- Bootstrap -->
    <link href="${pageContext.request.contextPath}/static/css/bootstrap.min.css" rel="stylesheet" media="screen">
    <script src="static/js/classgradeoperation.js"></script>
    <title>班级管理系统</title>
</head>

<script>
    // 接收第一页班级信息列表，初始化
    <%
        List<ClassGrade> ClassGradesList = (List<ClassGrade>) session.getAttribute("ClassGradesList");
        int totalPages = (int) session.getAttribute("totalPages");
        int i = 0;
        for (ClassGrade ClassGrade: ClassGradesList){
            if (ClassGrade != null){
    %>
    classGrades[<%=i%>] = new classGrade("<%=ClassGrade.getClassId()%>", "<%=ClassGrade.getClassName()%>","<%=ClassGrade.getGrade()%>","<%=ClassGrade.getTeacherName()%>","<%=ClassGrade.getSlogan()%>","<%=ClassGrade.getStudentNumber()%>");
    <%
    i++;}
    %>
    <%
            }
    %>

</script>

<body onload="refresh(classGrades)">

<div class="container">
    <table class="table" id="table">
        <!-- <caption> 关于表格存储内容的描述或总结。 -->
        <caption>
            <h2>班级管理界面</h2>
        </caption>
        <caption>
            <button class="btn btn-info" id="add" data-toggle="modal" data-target="#myModal" >新增</button>
            <button class="btn btn-info" id="delete" onclick="return del()">删除</button>
            <button class="btn btn-info" id="edit" data-toggle="modal" data-target="#myModal" onclick="return edit()">编辑</button>
            <div class="find">
                <form action="queryClassGradeServlet" method="post">
                    <input id="find-text" type="text" name="key" placeholder="输入班级编号" style="widows: 130px;">
                    <input class="find-btn" type="submit" value="查询">
                </form>
            </div>
        </caption>
        <thead>
        <tr>
            <th>序号</th>
            <th>班级编号</th>
            <th>班级名称</th>
            <th>年级</th>
            <th>班主任姓名</th>
            <th>口号</th>
            <th>人数</th>
        </tr>
        </thead>
        <tbody class="tbody" id="tbody">
        </tbody>
    </table>
    <%
        int currentPage = Integer.parseInt((String) session.getAttribute("currentPage"));
    %>
    <%
        if (totalPages >= 1){
    %>
    <ul class="pagination">
        <li > <a href="classGradePageQueryServlet?page=1"> 首页 </a> </li>
        <%
            if (currentPage > 1){
        %>
        <li class="previous"> <a href="classGradePageQueryServlet?page=<%=currentPage-1%>"> &laquo; </a> </li>
        <%
            }
        %>
        <%
            for (int j=1; j<=totalPages; j++){
        %>
        <li> <a href="classGradePageQueryServlet?page=<%=j%>"><%=j%></a> </li>
        <%
            }
        %>
        <%
            if (currentPage < totalPages){
        %>
        <li class="next"> <a href="classGradePageQueryServlet?page=<%=currentPage+1%>">&raquo;</a> </li>
        <%
            }
        %>

        <li > <a href="classGradePageQueryServlet?page=<%=totalPages%>">尾页</a> </li>
        <li style="text-align: center; vertical-align: middle; color: #2e6da4; font-size: 1.25em"> &nbsp;&nbsp;&nbsp;共<%=totalPages %>页 </li>
    </ul>
    <%
        }
    %>

    <!-- 模态框 -->
    <!-- 声明定义模态框组件 -->
    <div class="modal" id="myModal" role="dialog">
        <!-- 窗口声明 -->
        <div class="modal-dialog">
            <!-- 内容声明 -->
            <div class="modal-content">
                <!-- 1.框的标题 -->
                <!-- data-dismiss="modal" 取消的属性 -->
                <div class="modal-header">
                    <button class="close" data-dismiss="modal" aria-hidden="true">
                        <span>&times;</span>
                    </button>
                    <h4 class="modal-title">新增班级</h4>
                </div>
                <form action="addClassGradeServlet" method="post">
                    <!-- 2.框内信息 -->
                    <div class="modal-body">
                        <label for="id">班级编号:</label>
                        <input name="id" type="text" class="form-control" id="class_id" placeholder="请输入班级编号">
                        <label for="name">班级名称:</label>
                        <input name="className" type="text" class="form-control" id="class_name" placeholder="请输入班级名称">
                        <label for="grade">年级:</label>
                        <input name="grade" type="text" class="form-control" id="class_grade" placeholder="请输入年级">
                        <label for="teacherName">班主任名称:</label>
                        <input name="teacherName" type="text" class="form-control" id="teacher_name" placeholder="请输入班主任名称">
                        <label for="slogan">口号:</label>
                        <input name="slogan" type="text" class="form-control" id="class_slogan" placeholder="请输入口号">
                        <label for="number">人数:</label>
                        <input name="studentNumber" type="text" class="form-control" id="student_number" placeholder="请输入人数">
                    </div>
                    <!-- 3.框的按钮 -->
                    <div class="modal-footer">
                        <button class="btn btn-primary" type="submit" onclick="return alert('操作成功')">提交</button>
                        <button class="btn btn-default" type="reset" data-dismiss="modal">取消</button>
                    </div>
                </form>

            </div>
        </div>
    </div>

</div>

<script src="static/js/jquery-3.3.1.min.js"></script>
<script src="static/js/bootstrap.min.js"></script>

</body>




</html>